﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Http;
using System.IO;
using System.Web.Http;
using ExpenseSystem.Core;
using ExpenseSystem.Core.Authority;
using ExpenseSystem.Core.Converter;
using ExpenseSystem.Core.BonusModules;
using ExpenseSystem.Fether;
using ExpenseSystem.Common;
using ExpenseSystem.Lor;
using ExpenseSystem.Model;
using ExpenseSystem.Common.BaseModel;

namespace ExpenseSystem.Controllers
{
    [RoutePrefix("api/Other")]
    public class OtherController : ApiController
    {
        readonly SetInhibition setInhibition;
        readonly GetInhibition getInhibition;
        SetInhibitionMaker inhibitionMaker = new StateInhibitionMaker();
        GetInhibitionMaker getInhibitionMaker = new GetInhibitionMaker();
        public OtherController()
        {
            setInhibition = inhibitionMaker.Make();
            getInhibition = getInhibitionMaker.Make();
        }

        readonly OtherFetcher fetcher = new OtherFetcher();
        readonly OtherManager manager = OtherManager.CreateInstance();
        [Route("Export")]
        [HttpGet]
        public ResponseModel Export([FromUri]RequestArgs paramModels)
        {
            ExpFetcher<OtherExp> fetcher = new ExpFetcher<OtherExp>();
            return NormalControllerHelper.Export(fetcher, "EXP_OTHER_LIST", RestainConverter.FromRequestArgs(paramModels));
        }
        [Route("List")]
        [HttpGet]
        public ResponseModel List([FromUri]RequestArgs paramModels)
        {
            return NormalControllerHelper.List(fetcher, "EXP_OTHER_LIST", paramModels, getInhibition);
        }
        [Route("Get")]
        [HttpGet]
        public ResponseModel Get(long id)
        {
            return NormalControllerHelper.Get(fetcher, "EXP_OTHER_LIST", id, getInhibition);
        }

        [Route("Set")]
        [HttpPost]
        public ResponseModel Set(OtherModel data)
        {
            return NormalControllerHelper.Set(fetcher, "EXP_OTHER_SET", data, manager, setInhibition, getInhibition);
        }

        [Route("Remove")]
        [HttpPost]
        public ResponseModel Remove(OtherModel data)
        {
            return NormalControllerHelper.Remove("EXP_OTHER_DEL", data, manager);
        }

        [Route("RemoveById")]
        [HttpGet]
        public ResponseModel RemoveById([FromUri]long[] id)
        {
            return NormalControllerHelper.RemoveById("EXP_OTHER_DEL", id, manager);
        }

        [Route("Approve")]
        [HttpGet]
        public ResponseModel Approve([FromUri]long id)
        {
            return NormalControllerHelper.Approved("EXP_OTHER_APP", id, manager);
        }
        [Route("Revert")]
        [HttpGet]
        public ResponseModel Revert([FromUri]long id)
        {
            return NormalControllerHelper.Revert("EXP_OTHER_APP", id, manager);
        }
        [Route("Submit")]
        [HttpGet]
        public ResponseModel Submit([FromUri]long id)
        {
            return NormalControllerHelper.Submit("EXP_OTHER_SET", id, manager);
        }
        [Route("Recall")]
        [HttpGet]
        public ResponseModel Recall([FromUri]long id)
        {
            return NormalControllerHelper.Recall("EXP_OTHER_SET", id, manager);
        }
        [Route("Reject")]
        [HttpGet]
        public ResponseModel Reject([FromUri]long id)
        {
            return NormalControllerHelper.Reject("EXP_OTHER_APP", id, manager);
        }
        [Route("Comfirm")]
        [HttpGet]
        public ResponseModel Comfirm([FromUri]long id)
        {
            return NormalControllerHelper.Comfirm("EXP_OTHER_CFM", id, manager);
        }
    }
}
